home *** CD-ROM | disk | FTP | other *** search
- rved.
- *
- * YOUR RIGHTS WITH RESPECT TO THIS SOFTWARE IS GOVERNED BY THE
- * TERMS AND CONDITIONS SET FORTH IN THE CORRESPONDING EULA.
- *
- **
- --->
-
- <cfmodule template="../tags/bts_layout.cfm" exampleName="Custom Tags Example"
- source="index.cfm,tempconverter.cfm"
- keyTags="cfparam@Tags73.html,setVariable()@Functions211.html">
-
- <p>
- One of the easiest and most powerful ways to extend the functionality of
- ColdFusion is with custom tags. ColdFusion custom tags wrap
- functionality in one or more ColdFusion pages, which you can call from
- any other page. This lets you add your own tags to the CFML language.
- You can write your own custom tags or use prebuilt custom tags that have
- been created by other developers. Macromedia offers a
- <a href="http://devex.macromedia.com/developer/gallery/">Developer's Exchange</a> where you can
- download many custom tags for use in your applications.
- </p>
-
- <p>
- In the Custom Tags example, the temperature and scale from which to
- convert are passed as attributes to the custom tag, cf_tempconverter.
- The custom tag processes the conversion and returns the new value to the
- calling page as a variable called temp, which then displays on the page.
- </p>
-
- <p>
- This modular approach to building applications provides benefits, such
- as easing code reuse, simplifying maintenance, and allowing distribution
- of application functionality.
- </p>
-
- </cfmodule><!---
- **
- * CFMX Example Applications
- *
- * Copyright (c) 2002 Macromedia. All Rights Reserved.
- *
- * YOUR RIGHTS WITH RESPECT TO THIS SOFTWARE IS GOVERNED BY THE
- * TERMS AND CONDITIONS SET FORTH IN THE CORRESPONDING EULA.
- *
- **
- --->
-
- <cfmodule template="../tags/layout.cfm" pageName="Custom Tags Example">
-
- <p>
- This example shows the use of custom tags. Custom tags are a powerful
- way to add complex functionality to your web application.
- </p>
-
- <cfparam name="form.scaleFrom" default="F">
-
- <!---
- Based on the Scale abbreviation, set the display name of
- the 'To' and 'From' scales.
- --->
- <cfif IsDefined("form.temp") and isNumeric(form.temp)>
- <cfif form.scaleFrom eq "F">
- <cfset scaleFromName = "Fahrenheit">
- <cfset scaleToName = "Celsius">
- <cfelse>
- <cfset scaleFromName = "Celsius">
- <cfset scaleToName = "Fahrenheit">
- </cfif>
-
- <!---
- This is where we actually call the custom tag.
- Note how we pass the variables.
- --->
- <cf_tempconverter scale="#scaleFromName#" Temperature="#form.temp#" returnVariable="temp">
-
- <cfoutput>
- <p>
- #form.Temp# degrees #scaleFromName# = #temp# degrees #ScaleToName#
- </p>
- </cfoutput>
-
- </cfif>
-
- <!---
- The preserveData attribute will show the temperature in
- its text box after the form has been posted.
- --->
- <cfform action="#cgi.script_name#"
- method="post"
- preserveData="Yes">
-
- <p>
- Convert Temperature from <cfinput type="Text" name="Temp" message="Temperature must be numeric." validate="float" required="Yes"> degrees
- </p>
-
-
- <table>
- <tr><td colspan="2">Scale:</td></tr>
- <tr>
- <td>Fahrenheit</td>
- <td><cfinput type="radio" name="scaleFrom" value="F" checked></td>
- </tr>
- <tr>
- <td>Celsius</td>
- <td><cfinput type="radio" name="scaleFrom" value="C"></td>
- </tr>
- </tab